package cn.agiledata.bank.common.service;

import java.util.Date;
import java.util.Map;

import cn.agiledata.bank.common.dao.ActionTypeTemplate;
import cn.agiledata.bank.common.util.Constant;
import cn.agiledata.bank.common.util.DateUtil;
import cn.agiledata.bank.common.util.WeatherUtil;
import cn.agiledata.bank.hibernateBean.ScoresHis;
import cn.agiledata.bank.hibernateBean.SubAccount;
import cn.agiledata.bank.hibernateBean.Transaction;
import com.vnv.infrastructure.logic.IPBAppFactory;

public class WaitingPayNotifyMail extends NotifyMail {

	protected SubAccount setMailContext(Map vnvMap, Transaction tran,
			ScoresHis score) {
		   ActionTypeTemplate at = (ActionTypeTemplate) IPBAppFactory.getObj("actionTypeTemplate");
		SubAccount emailTo = tran.getDebit();
		vnvMap.put("tranId", tran.getTransId());
		String now = DateUtil.date2String(new Date());
		vnvMap.put("tranTime", now);
		String transtype;
		if(tran.getTradeType().equals(Constant.TRANTYPE_ASSURE)){
			transtype = "担保交易";
		}else{
			transtype="非担保交易";
		}
		vnvMap.put("transtype",transtype );
		String status = at.getTransStatusById(tran.getTransStatus()).getListName();
		vnvMap.put("transstatue", status);
		vnvMap.put("debit", WeatherUtil.getNameOrEmailOrMobileByAccount(tran.getDebit().getAccount()));
		vnvMap.put("credit", WeatherUtil.getNameOrEmailOrMobileByAccount(tran.getCredit().getAccount()));
		vnvMap.put("trantype","交易");
		vnvMap.put("amount", tran.getAmount().toString());
		vnvMap.put("fee", tran.getCreditFee().toString());
		double trueamount = tran.getAmount().doubleValue()+tran.getCreditFee().doubleValue();
		vnvMap.put("trueamount", trueamount+"");
		String titlemessage=tran.getCredit().getAccount().getName()+"向您收取了一笔款项,即将到期：";
	    vnvMap.put("warn", "请您确认，您可以到待处理交易中进行付款操作或者取消收款"+
	    		"以下是该笔待处理列表地址，请点击："+"<a href=\""+getUrl()+
				"/route.do?modual=manage$query\" target=\"_blank\">"+getUrl()+"/route.do?modual=manage$query</a><br/>"+
				"如果您点击上述链接无效，请把上面的代码拷贝到浏览器的地址栏中。");
	    vnvMap.put("titlemessage", titlemessage);
		return emailTo;
	}
}
